<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // new Promise(function(resolve,reject){
        //     if (false) {
        //         resolve('success')
        //     } else{
        //         reject('fail')
        //     }
        // }).then((result)=>{alert(result)})
        // .catch((error)=> alert(error))

        // Promise.reject可以手动抛出一个错，终止执行链的执行
        new Promise(function(resolve, reject) {
                resolve(1)
            }).then(result => {
                return result + 1
            }).then(result => {
                return result + 1
            }).then(result => {
            return  Promise.reject(new Error(result + '失败'))
            // return result + 1
            }).then(result => {
                return result + 1
            }).catch(error => {	
                alert(error)
            })

    </script>
</head>
<body>
    
</body>
</html>